import React,{useState,useEffect} from "react"
import axios from "axios"
export const withLoading = (Component,userId )=>{
    return props=>{
        const [user,setUser] = useState(null);

        useEffect(()=>{
            (async()=>{
                const response  = await axios.get(`/user/${userId}`)
                setUser(response.data);
            })()
        },[])
        return <Component {...props} user={user} ></Component>
    }
}